<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
    <%@taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<jsp:include page="/common/commonCss.jsp" />
<jsp:include page="/common/commonJs.jsp" />
<title>嘉童游乐中心-商品入库清单</title>
</head>
	<script type="text/javascript">
		$(document).ready(function(){
			createTable();
		});
		
		//显示表格
		function createTable()
		{
			//为表单参数赋值
			var s = "${inStgEntity['fkPurordId']}";
			var pkInstgId = "${pkInstgId}";
			$("#findPurordId").val(s);
			$("#findInstgId").val(pkInstgId);
			$("#fkInstgId").val(pkInstgId);
			$.ajax({
				url:"findGblScmPrdEntityForDetail.shtml",
				data:$("#stockDetailForm").serialize(),
				dataType:"json",
				type:"post",
				async:false,
				success:function(result)
				{
					initTable(result);
				},
				error : function(XMLHttpRequest) {
					ajaxError(XMLHttpRequest);
				}
			});
		}
		
		function initTable(data) {
			if(data == null)
				{
					return;
				}
			$.each(data, function(ind, obj)
			{
			  var msg = "";
			  var i = ind+1;
			  var htm="<tr>";
			  htm += "<td>" +i + "</td>";
			  htm += "<td>" + removeNull(obj.pkPrdId) + "</td>";
		      htm += "<td>" + removeNull(obj.prdName) + "</td>";
		      htm += "<td>"+ removeNull(obj.cateName)+"</td>";
		      htm += "<td>" + removeNull(obj.prdSpec)+ "</td>";
		      htm += "<td>" + removeNull(obj.unitName) + "</td>";
		      var purCnt = obj.purCnt == null ? 0: obj.purCnt;
		      htm += "<td>" + purCnt + "</td>";
		      var total = obj.instgCnt == null ? 0: obj.instgCnt;
		      htm += "<td>"+(obj.prdInstgCnt == null ? 0 : obj.prdInstgCnt)+"</td>";
		      htm += "<td>"+total+"</td>";
		      var comm = obj.comments;
		      
				if(comm !=null && comm.length > 15 )
					{
						msg = comm.substr(0,15) + "...";
					}
					else if(comm == null)
					{
						msg = "";
					}
					else
					{
						msg = comm;
					}
		      htm += "<td title = '"+comm+"'>"+msg+"</td></tr>";
	      
	      $("#stockDetail").find("tr:eq("+ind+")").after(htm);
			});
		}
		
		function removeNull(args)
		{
			return (args == null ? "": args);
		}
		
		function downloadFilFun()
		{
			$("#downloadFileForm")[0].submit();
		}
	</script>
</head>
<body class="bg">
<div class="content m_auto">
	<div class="content_l mt10">
    	<ul>
        		<shiro:hasPermission name="StockGoodsIn/toStock_goodsIn.shtml">
				<li class="content_hover"><a href="${basePath}StockGoodsIn/toStock_goodsIn.shtml"><i class="nav_icon_b"></i><br>商品入库</a></li>
			</shiro:hasPermission>
			<shiro:hasPermission name="StockQuery/toStockQuery.shtml">
				<li><a href="${basePath}StockQuery/toStockQuery.shtml"><i class="nav_icon_b"></i><br>库存查询</a></li>
			</shiro:hasPermission>
			<shiro:hasPermission name="StockGoodsOut/toStockGoodsOut.shtml">
				<li><a href="${basePath}StockGoodsOut/toStockGoodsOut.shtml"><i class="nav_icon_b"></i><br>商品出库</a></li>
			</shiro:hasPermission>
			<shiro:hasPermission name="StockTaking/toStockTaking.shtml">
				<li><a href="${basePath}StockTaking/toStockTaking.shtml"><i class="nav_icon_a"></i><br>库存盘点</a></li>
			</shiro:hasPermission>
			<shiro:hasPermission name="StockCorrect/toStockCorrect.shtml">
				<li><a href="${basePath}StockCorrect/toStockCorrect.shtml"><i class="nav_icon_f"></i><br>库存调整</a></li>
			</shiro:hasPermission>
			</ul>
    </div>
    <div class="content_r mt10">
    	<div class="p20">
    	<div class="file_single_dl f14 fixed">
        	 <dl class="fixed"  >
            	 <label><h1>商品入库清单 </h1></label>              
            </dl>
            <hr>
       		 <dl class="fixed"  > 
                <dd > <label>入库单编号：</label>${pkInstgId}</dd> <dd  > <label>订单编号：</label>${inStgEntity['fkPurordId']}</dd>
            </dl>
            <hr>
        	<dl class="fixed" style="overflow:hidden">
            	<dd><label>收货仓库：</label>${inStgEntity['branName']}</dd>
                <dd><label>制单人：</label>${inStgEntity['usrName']}</dd>
                <dd><label>制单时间：</label>${Time}</dd>
            </dl>
            <hr>
             <dl class="fixed"  >
             <dd class="lv">
					<label>入库单附件下载：</label>
					<a href="" onclick="downloadFilFun();return false" target="_blank">${inStgEntity['attFile']}</a>
				</dd>
            </dl>
             
        </div>
       <form id="stockDetailForm"  method="post">
	       <input type="hidden" name="fkPurordId" id="findPurordId" />
	       <input type="hidden" name="pkInstgId" id="findInstgId">
	       <input type="hidden" name="fkInstgId" id="fkInstgId">
       </form>
       <form action="${basePath}common/downloadAttFile.shtml" id="downloadFileForm" method="post">
       		<input type="hidden" name="attFile" value="${inStgEntity['attFile']}">
       		<input type="hidden" name="key" value="${key}">
       </form>
        <div class="mt10">
          	<ul class="fixed" id="tab_conbox_a">
                <li class="p10 h450" style="margin-left:10px">
                	<table class="table" id="stockDetail">
                    	<tr>
                        	<th>序号</th>
                            <th>商品编号</th>
                            <th>商品名称</th>
                            <th>商品分类</th>
                            <th>规格</th>
                            <th>单位</th>
                            <th>应收数量</th> 
                            <th>实际数量</th> 
                             <th>累计数量</th> 
                             <th>备注</th>  
                        </tr>
                    </table>
                    <!----底部按钮----->
                    	<div class="btm_btn m10">
                            <dl>
                        	    <dd><input class="btn" type="button" value="打印" ></dd>
                                <dd><input class="btn" type="button" value="返回" onclick="javascript:history.go(-1);"></dd>
                            </dl>
                        </div>
                   <!----底部按钮----->
                </li>
                </ul>
                </div>
        </div>
    </div>
</div>
</body>
</html>
